import os

import requests

videourl="https://upos-sz-mirrorcos.bilivideo.com/upgcxcode/71/23/187012371/187012371-1-30116.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1649260699&gen=playurlv2&os=cosbv&oi=1857570355&trid=f5cf58eef2eb44b399822fc8c4e71117u&platform=pc&upsig=3f440384360b81cdd783ffc8a8fa3d84&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=663816254&bvc=vod&nettype=0&orderid=0,3&agrr=0&bw=732412&logo=80000000"

# 请求头
headers={
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
    "cookie": "buvid3=ABEF4A37-D847-0287-3713-DA83481AD84359435infoc; i-wanna-go-back=-1; _uuid=223E8449-782F-C24B-10BD4-C15EB1028DEDA59600infoc; buvid4=3182C943-94E1-E33E-6F74-74B43B04052160109-022030913-ZDn+Yby5P8CiJMeEDas4Sg%3D%3D; buvid_fp_plain=undefined; buvid_fp=200c25186e24aab3da4814e8b7af48d8; SESSDATA=3915f380%2C1662356768%2C0e5d0%2A31; bili_jct=4cd8192d66145a47b3f6c70c417ea2e5; DedeUserID=663816254; DedeUserID__ckMd5=e33644a7ec719423; sid=js58jto8; b_ut=5; blackside_state=1; rpdid=|(u)l~lYmY)J0J'uYRY)|R~)m; CURRENT_BLACKGAP=0; nostalgia_conf=-1; LIVE_BUVID=AUTO6716482057114804; CURRENT_QUALITY=120; fingerprint3=4b16438872eba2c72aee28a11b730513; fingerprint=081d6f33f00fc9266d0ba97881ed68db; CURRENT_FNVAL=4048; PVID=2; b_lsid=28510B72F_17FFF10DD6F; bsource=search_baidu; innersign=1; bp_video_offset_663816254=646002646636822500",
    "referer": "https://www.bilibili.com/"
}

response=requests.get(url=videourl,headers=headers)

# 可以直接讲本数据包进行mp4形式保存
with open("高清.mp4","wb")as file1:
    file1.write(response.content)

audiourl="https://upos-sz-mirrorcos.bilivideo.com/upgcxcode/71/23/187012371/187012371-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1649260699&gen=playurlv2&os=cosbv&oi=1857570355&trid=f5cf58eef2eb44b399822fc8c4e71117u&platform=pc&upsig=f77ae487a0e9f4440a306509f476009b&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=663816254&bvc=vod&nettype=0&orderid=0,3&agrr=0&bw=40026&logo=80000000"

# 请求头
headers={
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
    "referer": "https://www.bilibili.com/"
}

response=requests.get(url=audiourl,headers=headers)

# 可以直接讲本数据包进行mp4形式保存
with open("高清.mp3","wb")as file1:
    file1.write(response.content)


os.system("ffmpeg -i 高清.mp4 -i 高清.mp3 -c copy 视频1.mp4")



